#include "ThreadPool.hpp"
#include "Task.hpp"
#include "Log.hpp"

void Add()
{
    std::cout << "2" << std::endl;
}

int main()
{
    //ThreadPool<Task> tp(5);
    ThreadPool<Task>& tp = ThreadPool<Task>::GetInstance(5);
    ThreadPool<Task>& tp2 = ThreadPool<Task>::GetInstance(6);
    LOG(INFO, "%d threads", tp2.GetNewThreads());
    Task t1(1, 1);
    // tp.Init();
    // tp.Start();
    int cnt = 5;
    //Log log(__FILE__, __LINE__, DEBUG, "this is a test", LogToScreen);
    //Log log(DEBUG, "this is a test", LogToScreen);
    LOG(DEBUG, "this %d test", 1);
    while (cnt)
    {
        tp.Enqueue(&t1);
        cnt--;
    }
    tp.Stop();
    tp.Join();

    sleep(1);
    // 在你的逻辑中，主线程没有join子线程，你是采用取消线程的方式，
    // 但是由于过程中有一定的时序性问题，而导致主线程执行完Stop优先从线程退出,
    // tp被销毁，而子进程可能还在front/pop tp中的_taskqueue 而造成的段错误(内存错误)

    return 0;
}